{% extends "profile/base.html" %}

{% block title %}用户仪表板 - 用户资料管理系统{% endblock %}

{% block content %}
<div class="container">
    <!-- 欢迎标题 -->
    <div class="text-center mb-4 fade-in">
        <h1 class="fw-bold text-primary">
            <i class="fas fa-tachometer-alt me-2"></i>用户仪表板
        </h1>
        <p class="text-muted">欢迎回来，{{ user.nickname or user.username }}！</p>
    </div>

    <div class="row">
        <!-- 用户资料卡片 -->
        <div class="col-lg-4 mb-4">
            <div class="card shadow-sm h-100 fade-in">
                <div class="card-header bg-gradient text-white">
                    <h5 class="mb-0 text-center">
                        <i class="fas fa-user-circle me-2"></i>个人资料
                    </h5>
                </div>
                <div class="card-body text-center">
                    <div class="mb-3">
                        {% if user.avatar %}
                        <img src="{{ url_for('profile.uploaded_file', filename=user.avatar) }}" class="profile-avatar" alt="用户头像">
                        {% else %}
                        <div class="profile-avatar d-flex align-items-center justify-content-center bg-light text-secondary">
                            <i class="fas fa-user fs-1"></i>
                        </div>
                        {% endif %}
                    </div>
                    <h5 class="fw-bold">{{ user.nickname or user.username }}</h5>
                    <p class="text-muted">{{ user.email }}</p>
                    
                    <div class="d-grid gap-2">
                        <a href="{{ url_for('profile.edit_profile') }}" class="btn btn-outline-primary">
                            <i class="fas fa-edit me-2"></i>编辑资料
                        </a>
                        <a href="{{ url_for('profile.view_profile', user_id=user.id) }}" class="btn btn-outline-secondary">
                            <i class="fas fa-eye me-2"></i>查看资料
                        </a>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 用户信息卡片 -->
        <div class="col-lg-8 mb-4">
            <div class="card shadow-sm h-100 fade-in">
                <div class="card-header bg-gradient text-white">
                    <h5 class="mb-0">
                        <i class="fas fa-info-circle me-2"></i>账户信息
                    </h5>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <div class="card border-0 bg-light">
                                <div class="card-body text-center">
                                    <div class="mb-2">
                                        <i class="fas fa-calendar-plus text-primary fs-4"></i>
                                    </div>
                                    <h6 class="card-title">注册时间</h6>
                                    <p class="card-text">{{ user.created_at.strftime('%Y-%m-%d') if user.created_at else '未知' }}</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6 mb-3">
                            <div class="card border-0 bg-light">
                                <div class="card-body text-center">
                                    <div class="mb-2">
                                        <i class="fas fa-calendar-check text-success fs-4"></i>
                                    </div>
                                    <h6 class="card-title">最后更新</h6>
                                    <p class="card-text">{{ user.updated_at.strftime('%Y-%m-%d') if user.updated_at else '未知' }}</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <div class="card border-0 bg-light">
                                <div class="card-body text-center">
                                    <div class="mb-2">
                                        <i class="fas fa-globe text-info fs-4"></i>
                                    </div>
                                    <h6 class="card-title">资料状态</h6>
                                    <p class="card-text">
                                        {% if user.is_public %}
                                        <span class="badge bg-success">公开</span>
                                        {% else %}
                                        <span class="badge bg-secondary">私有</span>
                                        {% endif %}
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6 mb-3">
                            <div class="card border-0 bg-light">
                                <div class="card-body text-center">
                                    <div class="mb-2">
                                        <i class="fas fa-user-check text-warning fs-4"></i>
                                    </div>
                                    <h6 class="card-title">账户状态</h6>
                                    <p class="card-text">
                                        {% if user.is_active %}
                                        <span class="badge bg-success">活跃</span>
                                        {% else %}
                                        <span class="badge bg-danger">已禁用</span>
                                        {% endif %}
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 快速操作卡片 -->
    <div class="row">
        <div class="col-12">
            <div class="card shadow-sm fade-in">
                <div class="card-header bg-gradient text-white">
                    <h5 class="mb-0">
                        <i class="fas fa-rocket me-2"></i>快速操作
                    </h5>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-3 col-sm-6 mb-3">
                            <div class="d-grid">
                                <a href="{{ url_for('profile.edit_profile') }}" class="btn btn-primary btn-lg">
                                    <i class="fas fa-edit me-2"></i>编辑个人资料
                                </a>
                            </div>
                        </div>
                        <div class="col-md-3 col-sm-6 mb-3">
                            <div class="d-grid">
                                <a href="{{ url_for('profile.upload_file') }}" class="btn btn-success btn-lg">
                                    <i class="fas fa-upload me-2"></i>上传文件
                                </a>
                            </div>
                        </div>
                        <div class="col-md-3 col-sm-6 mb-3">
                            <div class="d-grid">
                                <a href="{{ url_for('profile.file_list') }}" class="btn btn-info btn-lg">
                                    <i class="fas fa-folder-open me-2"></i>文件列表
                                </a>
                            </div>
                        </div>
                        <div class="col-md-3 col-sm-6 mb-3">
                            <div class="d-grid">
                                <a href="{{ url_for('profile.view_profile', user_id=user.id) }}" class="btn btn-secondary btn-lg">
                                    <i class="fas fa-eye me-2"></i>查看我的资料
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_css %}
<style>
    .bg-gradient {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    
    .fade-in {
        opacity: 0;
        animation: fadeIn 0.5s ease-in forwards;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(20px); }
        to { opacity: 1; transform: translateY(0); }
    }
    
    .profile-avatar {
        width: 120px;
        height: 120px;
        border-radius: 50%;
        object-fit: cover;
        border: 4px solid #f8f9fa;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }
    
    .card {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        border-radius: 10px;
    }
    
    .card:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    }
    
    .btn-lg {
        padding: 12px 20px;
        font-weight: 500;
        transition: all 0.3s ease;
    }
    
    .btn-lg:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }
    
    .card-header {
        border-radius: 10px 10px 0 0 !important;
        border-bottom: none;
    }
</style>
{% endblock %}

{% block extra_js %}
<script>
    $(document).ready(function() {
        // 初始化动画
        $('.fade-in').each(function(index) {
            $(this).delay(100 * index).animate({ opacity: 1 }, 500);
        });
    });
</script>
{% endblock %}